<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form>
            <p:panel header="Handover Reports" >
                <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
                <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                    <h:panelGrid columns="2" styleClass="noPrintButton">
                        <h:outputLabel value="From Date"/>
                        <p:calendar value="#{pharmacySaleReport.fromDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss a"  >
                        </p:calendar>
                        <h:outputLabel value="To Date"/>
                        <p:calendar value="#{pharmacySaleReport.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss a" >
                        </p:calendar>
                        <h:outputLabel value="Instituion"/>
                        <p:autoComplete styleClass="noPrintButton"  value="#{pharmacySaleReport.institution}" completeMethod="#{institutionController.completeCompany}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                        </p:autoComplete>
                        <h:outputLabel value="Department"/>
                        <au:department value="#{pharmacySaleReport.toDepartment}" />
                    </h:panelGrid>

                    <h:panelGrid columns="4">
                        <p:spacer width="80" height="1"/>
                        <p:commandButton ajax="false" styleClass="noPrintButton" value="Process" action="#{pharmacySaleReport.createLabHadnOverReportByDate}"/>
                        <p:commandButton ajax="false" value="Excel" actionListener="#{pharmacySaleReport.createLabHadnOverReportByDate}" styleClass="noPrintButton" style="float: right;" >
                            <pe:exporter type="xlsx" target="sum1" fileName="report_pharmacy_sale_by_date_summery"  />
                        </p:commandButton>
                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>
                    </h:panelGrid>

                    <p:dataTable id="sum1" value="#{pharmacySaleReport.billedSummery.bills}" var="i">   
                        <f:facet name="header">
                            <p:outputLabel value="#{pharmacySaleReport.institution.name}" />
                            <br/>
                             <h:outputLabel value="Hand Over Report By Date"/><br/>
                            <h:outputLabel value="From : "/>
                            <h:outputLabel value="#{pharmacySaleReport.fromDate}">
                                <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                            </h:outputLabel>
                            <p:spacer width="30" height="1"/>
                            <h:outputLabel value="To :"/>
                            <h:outputLabel value="#{pharmacySaleReport.toDate}">
                                <f:convertDateTime pattern="dd MMM yyyy hh:mm:ss a"/>
                            </h:outputLabel>
                        </f:facet>

                        <p:column headerText="Date">
                            <f:facet name="header">
                                <h:outputLabel value="Date" />
                            </f:facet>
                            <h:outputLabel value="#{i.string}" />
                        </p:column>
                        <p:column headerText="Gross" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Gross" />
                            </f:facet>
                            <h:outputLabel value="#{i.value1}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Discount " styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Discount" />
                            </f:facet>
                            <h:outputLabel value="#{i.value2}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Professional" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Professional" />
                            </f:facet>
                            <h:outputLabel value="#{i.value3}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Net Value" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Net Value" />
                            </f:facet>
                            <h:outputLabel value="#{i.value1-(i.value2+i.value3)}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column footerText="Total  "/>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.cancelledTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.cancelledTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.refundedTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.refundedTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal-(pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal)}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal-(pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal)}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                            </p:row>
                        </p:columnGroup>
                        <f:facet name="footer">
                            <h:outputLabel style="float: right" value="Printed By : #{sessionController.loggedUser.webUserPerson.name} " />
                        </f:facet>
                    </p:dataTable>

                </p:panel>         
            </p:panel>

        </h:form>

    </ui:define>



</ui:composition>
